﻿using Nservice.Billing.Messages;
using Nservice.Billing.Server.Service;
using NServiceBus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nservice.Billing.Server
{
    public class CreditChargedHandler:IHandleMessages<CreditCharged>
    {
        public ICreditService CreditService { get; set; }
        public IBus Bus { get; set; }

        public void Handle(CreditCharged message)
        {
            CreditService.ChargedCredit(message.OrderId, message.Amount);
            Bus.Reply(new ChargedCredit {
                OrderId = message.OrderId,
                Receipt = "Sample Receipt"
            });
            
        }
    }
}
